package org.fly.main.base;

import cn.hutool.core.thread.NamedThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author:whh
 * @date: 2025-11-29 09:10
 * <p></p>
 */
@Configuration
public class ThreadPoolConfig {




    @Bean(name = "serialExecutor",destroyMethod = "shutdown")
    public ThreadPoolExecutor serialExecutor(){
        return new ThreadPoolExecutor(1,1,2L,
                TimeUnit.SECONDS,new ArrayBlockingQueue<>(3),new NamedThreadFactory("SerialExecutor-",true),new ThreadPoolExecutor.AbortPolicy());

    }
}
